package com.ktwlsoft.archivemanage.controller;

import com.ktwlsoft.archivemanage.domain.business.businessService.RecycleService;
import com.ktwlsoft.archivemanage.domain.business.repositoryService.businessInspect.BusinessInspectRepositoryService;
import com.ktwlsoft.archivemanage.payload.Result;
import com.ktwlsoft.archivemanage.payload.recycle.DeleteRequest;
import com.ktwlsoft.archivemanage.payload.recycle.QueryRecycleRequest;
import com.ktwlsoft.archivemanage.payload.recycle.RestoreRequest;
import com.ktwlsoft.archivemanage.service.security.UserAuthenticate;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@Api(description = "回收站")
@RestController
@RequestMapping("/recycle")
public class RecycleController {

    private final RecycleService recycleService;

    private final BusinessInspectRepositoryService businessInspectRepositoryService;

    public RecycleController(RecycleService recycleService, BusinessInspectRepositoryService businessInspectRepositoryService) {
        this.recycleService = recycleService;
        this.businessInspectRepositoryService = businessInspectRepositoryService;
    }

    @GetMapping("/findByPage")
    @ApiOperation("列表查询")
    @UserAuthenticate(actionCode = "RECYCLE_LIST", skip = true)
    public ResponseEntity<?> findByPage(QueryRecycleRequest request){
        return ResponseEntity.ok(recycleService.queryByPage(request));
    }

    @PostMapping("/restore")
    @ApiOperation("批量恢复")
    @UserAuthenticate(actionCode = "RECYCLE_RESTORE")
    public ResponseEntity<?> restore(@RequestBody RestoreRequest request) {
        return ResponseEntity.ok(recycleService.restore(request));
    }

    @ApiOperation("删除")
    @PostMapping("/delete")
    @UserAuthenticate(actionCode = "RECYCLE_DELETE")
    public ResponseEntity<?> delete(@RequestBody DeleteRequest request) {
        return ResponseEntity.ok(recycleService.delete(request));
    }
}
